/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
  <file> uls_config.h </file>
  <brief>
    The configuration header for building the ULS library
    This file is part of ULS, Unified Lexical Scheme.
  </brief>
  <author>
    Stanley J. Hong <babel96@gmail.com>, August 2011.
  </author>
*/

#ifndef __ULS_CONFIG_H__
#define __ULS_CONFIG_H__

#if defined(linux)
#include <endian.h>
#include "config.h"
#define LDOUBLE_MEMSIZE 12
#define HAVE_GETOPT_H
#elif defined(WIN32)
#define LDOUBLE_MEMSIZE 8
#define ULS_INST_DIR "C:\\Program Files\\uls-1.0"
#else
#include <endian.h>
#include "config.h"
#define LDOUBLE_MEMSIZE 12
#define HAVE_GETOPT_H
#endif

#define ULS_LEXSTR_MAXSIZ       31
#define ULS_2CHARS_TOKSIZ       15
#define ULS_TOKTOWER_DFLSIZ     16

#define ULS_COMM_MARK_MAXSIZ    15
#define ULS_N_MAX_COMMTYPES      4
#define ULS_QUOTE_MARK_MAXSIZ    7
#define ULS_N_MAX_QUOTETYPES     8
#define ULS_N_CHARSET_RANGES     8
#define ULS_MAGICCODE_SIZE      80

#define ULS_ISTR_LITERALS_MAX   15
#define ULS_FILEPATH_MAX      1023

#define ULS_SYNTAX_TABLE_SIZE  256

#define ULS_TXT_RECHDR_SZ       64
#define ULS_BIN_RECHDR_NUM_INT32 2
#define ULS_BIN_RECHDR_SZ (ULS_BIN_RECHDR_NUM_INT32*sizeof(uls_int32))

#define ULF_HASH_TABLE_SIZE    111
#define ULF_MAXDIM_HASHSPACE   4

#define ULC_VERSION_MAJOR     2
#define ULC_VERSION_MINOR     0
#define ULC_VERSION_DEBUG     0
#define ULC_VERSION_SEQUENCE  0

#define ULS_VERSION_STREAM_MAJOR     2
#define ULS_VERSION_STREAM_MINOR     0
#define ULS_VERSION_STREAM_DEBUG     0
#define ULS_VERSION_STREAM_SEQUENCE  0

#define ULF_VERSION_MAJOR     1
#define ULF_VERSION_MINOR     0
#define ULF_VERSION_DEBUG     0
#define ULF_VERSION_SEQUENCE  0

#define ULF_VERSION_HASHFUNC_MAJOR     1
#define ULF_VERSION_HASHFUNC_MINOR     0
#define ULF_VERSION_HASHFUNC_DEBUG     0
#define ULF_VERSION_HASHFUNC_SEQUENCE  0

#define ULS_VERSION_CODE_LEN   4
#define ULS_VERSION_STR_MAXLEN 15

#if defined(WIN32)
#define ULS_CONFIG_DIR ULS_INST_DIR "\\share"
#define ULS_CONFIG_DFLDIR  "C:\\Program Files;C:\\Temp"
#define ULS_DELIMCH_DIRPATH ';'
#else
#define ULS_DELIMCH_DIRPATH ':'
#define ULS_CONFIG_DIR  ULS_INST_DIR "/share"
#define ULS_CONFIG_DFLDIR  "/usr/local/share:/usr/local/lib/share:/usr/lib/share"
#endif

#define ULS_VERSION_STR    "1.0"
#define ULS_GEN_PROGVER    "v1.0"
#define ULF_GEN_PROGVER    "v1.0"
#define ULS_STREAM_PROGVER "v1.0"
#define ULS_INITIAL_NAME   "ULS(Unified Lexical Scheme)"
#define ULS_LICENSE_NAME   "Apache License 2.0"
#define ULS_AUTHOR         "Stanley J. Hong (babel96@gmail.com)"
#define ULS_GREETING       ULS_INITIAL_NAME " " ULS_VERSION_STR ", written by " ULS_AUTHOR "."

#if defined(WIN32)
	#include <windows.h>
	typedef struct _uls_mutex_struct uls_mutex_struct_t;
	typedef struct _uls_mutex_struct *uls_mutex_t;
	struct _uls_mutex_struct {
		HANDLE hndl;
	};
	#define DECLARE_ULS_MUTEX(name) uls_mutex_struct_t name
#elif defined(HAVE_LIBPTHREAD)
	#include <pthread.h>
	#define DECLARE_ULS_MUTEX(name) pthread_mutex_t name
	#define uls_mutex_struct_t pthread_mutex_t
	typedef pthread_mutex_t *uls_mutex_t;
#else
	#define DECLARE_ULS_MUTEX(name) int name
	#define uls_mutex_struct_t int
	typedef int *uls_mutex_t;
#endif

extern void uls_init_mutex(uls_mutex_t mtx);
extern void uls_deinit_mutex(uls_mutex_t mtx);
extern void uls_lock_mutex(uls_mutex_t mtx);
extern void uls_unlock_mutex(uls_mutex_t mtx);

#endif
